<?php

namespace iBrand\Shop\Server\Resources;

use iBrand\Common\Resources\BaseResource;
use iBrand\Component\Goods\Models\SpecsValue;

class StockQueryResource extends BaseResource
{
	public function toArray($request)
	{
		$specID = $this->resource->baseProduct->specID;
		$spec0  = SpecsValue::find($specID[0]);
		$spec1  = SpecsValue::find($specID[1]);
		if ($spec0->spec_id == 1) {
			$this->resource->spec_text = $spec1->name . ',' . $spec0->name;
		} elseif ($spec1->spec_id == 1) {
			$this->resource->spec_text = $spec0->name . ',' . $spec1->name;
		}

		return parent::toArray($request);
	}
}